package com.h2cloud.clone.test.test1;

/**
 * @author: wulongkai
 * @create: 2022-09-26 16:29
 **/
class Son {
    String name;
    int age;

    public Son(String name, int age) {
        this.name = name;
        this.age = age;
    }
}

// 引用拷贝
public class test1 {
    public static void main(String[] args) {
        Son s1 = new Son("son1", 12);
        Son s2 = s1;
        s1.age = 22;
        s2.name = "son2";
        System.out.println(s1);
        System.out.println(s2);
        System.out.println("s1的 age:" + s1.age);
        System.out.println("s2的 age:" + s2.age);
        System.out.println("s1==s2" + (s1 == s2));//相等

        System.out.println("s1的 name:" + s1.name);
        System.out.println("s2的 name:" + s2.name);
        System.out.println("s1.name == s2.name:" + (s1.name == s2.name));//相等
    }
}
